﻿using Modles.DTO;
using Modles.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BilbilDAL
{
    public class AccountDAL
    {
        public UserInfo Login(Login_DTO model)
        {
            using (VideoPlatformDbContext con = new VideoPlatformDbContext())
            {
                User user = con.Users.FirstOrDefault(x => x.Account == model.Account && x.Password == model.Password);
                if (user != null)
                {
                    UserInfo userInfo = con.UserInfos.Find(user.UserInfoId);
                    if (userInfo != null)
                    {
                        return userInfo;
                    }
                }
                return null;
            }
        }
    }
}
